package adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.administrator.newxlmedical.R;

import java.util.List;

import beans.ComboInfoBean;
import beans.WarningInfoBean;
import butterknife.BindView;
import butterknife.ButterKnife;
import custom.BaseRecyclerAdapter;

/**
 * Created by Administrator on 2018/11/12.
 */

public class ComboInfoAdapter extends BaseRecyclerAdapter<ComboInfoAdapter.ComboInfoViewHolder> {
    private Context mContext;
    private List<ComboInfoBean.DataBean> list;

    public ComboInfoAdapter(Context mContext, List<ComboInfoBean.DataBean> list) {
        this.mContext = mContext;
        this.list = list;
    }

    @Override
    public ComboInfoAdapter.ComboInfoViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(mContext).inflate(R.layout.adapter_combo_info, parent, false);
        return new ComboInfoViewHolder(inflate);
    }

    @Override
    public void onBindViewHolder(ComboInfoAdapter.ComboInfoViewHolder viewHolder, int position) {
        ComboInfoBean.DataBean dataBean = list.get(position);
        viewHolder.tvName.setText(dataBean.getGoodName());
        viewHolder.tvSpecification.setText(dataBean.getSpecification());
        viewHolder.tvSuppier.setText(dataBean.getManufacturer());

        if (position % 2 == 0) {
            viewHolder.llAdapter.setBackgroundColor(mContext.getResources().getColor(R.color.partLineBackground));
        } else {
            viewHolder.llAdapter.setBackgroundColor(mContext.getResources().getColor(R.color.white));
        }
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class ComboInfoViewHolder extends BaseRecyclerAdapter.BaseViewHolder {
        @BindView(R.id.tv_adapter_combo_info_name)
        TextView tvName;
        @BindView(R.id.tv_adapter_combo_info_specification)
        TextView tvSpecification;
        @BindView(R.id.tv_adapter_combo_info_suppier)
        TextView tvSuppier;
        @BindView(R.id.ll_search_adapter)
        LinearLayout llAdapter;

        ComboInfoViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
